package entity;

import org.hibernate.annotations.*;
import org.hibernate.annotations.Cache;

import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

/**
 * Created by xuweijie on 2017/4/20.
 * 个人优惠券实体
 */
@Entity
@Table(name = "cro_myqpon")
@DynamicInsert(true)
//@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class CroMyqpon implements Serializable {
    private String id;
    private CroCustomer croCustomer;
    private CroCoupons croCoupons;
    private Date offdate;
    private Date createdate;
    private Date usedate;
    private String status;
    private String del_flag;



    @Id
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @ManyToOne(cascade ={CascadeType.REFRESH},fetch =FetchType.EAGER)
    @JoinColumn(name ="costomid",referencedColumnName = "id")
    public CroCustomer getCroCustomer() {
        return croCustomer;
    }

    public void setCroCustomer(CroCustomer croCustomer) {
        this.croCustomer = croCustomer;
    }

    @OneToOne(cascade ={CascadeType.REFRESH},fetch =FetchType.EAGER)
    @JoinColumn(name ="qId",referencedColumnName = "id")
    public CroCoupons getCroCoupons() {
        return croCoupons;
    }

    public void setCroCoupons(CroCoupons croCoupons) {
        this.croCoupons = croCoupons;
    }

    public Date getOffdate() {
        return offdate;
    }

    public void setOffdate(Date offdate) {
        this.offdate = offdate;
    }

    @CreationTimestamp
    public Date getCreatedate() {
        return createdate;
    }

    public void setCreatedate(Date createdate) {
        this.createdate = createdate;
    }

    public Date getUsedate() {
        return usedate;
    }

    public void setUsedate(Date usedate) {
        this.usedate = usedate;
    }

    @Column(columnDefinition ="varchar(10) default '0'")
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    @Column(columnDefinition ="varchar(1) default '0'")
    public String getDel_flag() {
        return del_flag;
    }

    public void setDel_flag(String del_flag) {
        this.del_flag = del_flag;
    }
}
